<?php

class UserController extends BaseController
{
    private $req;

    public function init()
    {
        $this->req = $this->getRequest();
        if ($this->req->isXMLHttpRequest()) {
            Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer')->setNoRender(true);
            $layout = Zend_Layout::getMvcInstance();
            if ($layout instanceof Zend_Layout) {
                $layout->disableLayout();
            }
        }
        $this->view->breadcrumb = array(array(
            'url' => '/user/index',
            'name' => '用户管理',
        ));
    }

    public function indexAction()
    {
        $player_biz = new \Biz\User();
        $size = Page::ValidatePageSize($this->req->get('pageSize'), '/user/index'); //每页显示条数
        $now = $this->req->get('p') ? $this->req->get('p') : 1;//当前页数
        $where = '';
        $list_result = $player_biz->getUserList($where, $now, $size);
        $page = new Page($list_result['total'], $size, $now, '/user/index?', 2);
        $this->view->size = $size;
        $this->view->now = $now;
        $this->view->pageStr = $page->showPage();
        $this->view->list_result = $list_result['list'] ?? array();
        $this->view->breadcrumb = array(
            array(
                'name' => '用户列表',
            ));
    }
}